#ifndef __TASKQUEUE_H
#define __TASKQUEUE_H
#include "noncopyable.hpp"
#include "condition.hpp"
#include "mutexlock.hpp"
#include "thread.hpp"
#include <queue>
#include <functional>
using std::function;
namespace moqi
{
using ElementType = function<void()>;

class TaskQueue
{
public:
    TaskQueue(int);
    ~TaskQueue();
    void push(ElementType && element);
    ElementType pop();
    bool empty()const;
    bool full()const;
    void wakeupAll();
private:
    std::queue<ElementType> _que;
    size_t _queSize;
    MutexLock _mutex;
    Condition _notFull;
    Condition _notEmpty;
    bool _flag;
};
}
#endif //__TASKQUEUE_H
